package cn.sirun.com.fca.account.uitl;

import android.content.Intent;

import cn.sirun.com.fca.account.constant.AccountIntentConst;


/**
 * @author vinsonhuang
 * @date 2018/9/30
 */
public class IntentUtils {

    public static int getIntentFrom(Intent intent, int defaultValue) {
        if (null == intent || !intent.hasExtra(AccountIntentConst.FROM)) {
            return AccountIntentConst.UNKNOWN;
        }

        return intent.getIntExtra(AccountIntentConst.FROM, defaultValue);
    }

    public static boolean isAddVehicle(Intent intent, boolean defaultValue) {
        if (null == intent || !intent.hasExtra(AccountIntentConst.IS_ADD_VEHICLE)) {
            return false;
        }

        return getBooleanExtra(intent, AccountIntentConst.IS_ADD_VEHICLE, defaultValue);
    }

    public static boolean isReviewAuthInfo(Intent intent, boolean defaultValue) {
        if (null == intent || !intent.hasExtra(AccountIntentConst.IS_REVIEW_AUTH_INFO)) {
            return false;
        }

        return getBooleanExtra(intent, AccountIntentConst.IS_REVIEW_AUTH_INFO, defaultValue);
    }

    public static boolean getBooleanExtra(Intent intent, String name, boolean defaultValue) {
        if (null == intent) {
            return false;
        }
        return intent.getBooleanExtra(name, defaultValue);
    }
}
